1. Field of the Invention
This invention relates generally to Java system performance, and more particularly to systems and methods for low overhead Java array boundary checking.
2. Description of the Related Art
Today""s world of computer programming offers many high-level programming languages. Java, for example, has achieved widespread use in a relatively short period of time and is largely attributed with the ubiquitous success of the Internet. The popularity of Java is due, at least in part, to its platform independence, object orientation and dynamic nature. In addition, Java removes many of the tedious and error-prone tasks which must be performed by an application programmer, including memory management and cross-platform porting. In this manner, the Java programmer can better focus on design and functionality issues.
To execute a Java application, a Java processor is used, which is typically realized only by software in form of a Java Virtual Machine (JVM). However, because of the problems associated with implementing a process in software, the JVM is plagued with slow performance issues. Further, certain robustness features required to obtain Java certification for a JVM exacerbate the slow performance issues encountered in conventional JVMs.
One such robustness feature is array boundary checking. Thus, to get certification on a JVM, boundary checking must be performed whenever an array is accessed.
By way of background, many Java applications utilize arrays, which are an arrangement of information in one or more dimensions, e.g., a list, a table, or a multidimensional arrangement of data. Whenever an array is realized in memory using Java, the size of the array is stored in memory along with any data referenced by the array. Generally, the Java array size is stored as the first element in the array.
For example, a one-hundred element array in Java will have the number one-hundred stored as the first element of the array. Thus, in order to keep the required number of elements free for data storage, arrays in Java are typically larger than would otherwise need to be in order to store a particular number of elements.
As mention previously, as instructions are interpreted by a JVM, one the operations that must be performed by the interpreter is an array boundary check. Specifically, whenever a Java array is accessed by a Java application, an array boundary check must be performed to ensure that before the array is accessed, the array size is checked to make sure that the element attempting to be accessed is not outside the boundary of the array. In addition, the array reference itself is also checked to ensure that it is a valid array reference.
When an array access command attempts to access an element outside the boundary of the array an exception is triggered. In addition, an exception is triggered when an array access command is attempted with an invalid array reference. Generally, the raised exceptions are configured to prevent memory access when they are raised.
Array boundary checking results in a more robust system since array access commands have access only to those data elements defined by the array, and no access to adjacent data is possible, resulting in fewer bugs and improved system security. However, the step-by-step comparison and verification required for array boundary checking, which typically requires at least one cycle per step, consumes valuable processing time until a verification occurs.
Since JVMs have conventionally been implemented in software, boundary checking in JAVA is typically a process that adds extra machine cycles every time an array is accessed. The extra machine cycles utilized for array boundary checking greatly reduce the operating efficiency of the system, which only serves to further exacerbate an already slow, software-based, interpretive process.
In view of the forgoing, there is a need for improved methods for array boundary checking. The methods should reduce the overhead associated with array boundary checking, thereby significantly reducing the time required to retrieve array information and verify its size relative to conventional systems.
Broadly speaking, the present invention fills these needs by performing array boundary checking during the same machine cycles that are used to perform an array access command. By performing array boundary checking in parallel with the array access command, the array boundary checker of the present invention avoids the additional overhead conventionally associated with array boundary checking.
In one embodiment, an array boundary checking method is disclosed that provides hardware based array boundary checking in a Java environment. During the first machine cycle of a current array access command, an array reference value is loaded into a system-data address controller and an array boundary checker. Next, during the second machine cycle of the current array access command, an array index value is written to the system-data address controller and the array boundary checker. Also during the second machine cycle of the current array access command, a maximum array index value is written to the array boundary checker. The array boundary checker utilizes these values to determine the validity of the current array access command. Finally, during the third machine cycle an array value is accessed in memory. In the present invention the array value is only accessed when the current array access command is valid.
In another embodiment, an array boundary checking system that provides array boundary checking in a Java environment is disclosed. The array boundary checking system includes a system-data address controller that has a first array reference register and a first array index register. In addition the array boundary checking system includes an array boundary checker that is coupled to the system-data address controller via a first data bus and a second data bus. The array boundary checker includes a second array reference register, a second array index register, and a maximum array index register. In operation, the second array index register and the maximum array index register are capable of being loaded during a single machine cycle via the first data bus and the second data bus, thus saving machine cycles when performing array boundary checking.
Another array boundary checking method for providing hardware based array boundary checking in a Java environment is disclosed in yet another embodiment of the present invention. The method begins with an array reference value being written to an array reference register via a first data bus. Then, an array index value is loaded into an array index register using the first data bus. During the same machine cycle that the array index register is loaded, a maximum array index value is loaded into a maximum array index register using a second data bus. To determine the validity of a current array access command, the array reference value, the array index value, and the maximum array index value are analyzed.
Advantageously, the present invention provides array boundary checking without adding additional overhead to the system. By performing the array boundary checking in parallel with the actual array access, the present invention conforms with Java array boundary checking conventions without the need of extra machine cycles, thus greatly enhancing the performance of the Java processor. Moreover, the use of dual data buses allows multiple registers to be loaded during a single machine cycle, thus further enhancing the Java processor performance.
Other aspects and advantages of the invention will become apparent from the following detailed description, taken in conjunction with the accompanying drawings, illustrating by way of example the principles of the invention.